clear all

********************************************************************************
********************************************************************************
**** When Can We Trust Regression Discontinuity Design Estimates from Close ****
*************** Elections? Evidence from Experimental Benchmarks ***************
********************************************************************************
********************************************************************************

* This file produces Table OA14 in Online Appendix D of De Magalhaes et al. 
* (Political Analysis).

cd "$dir"
use "$dir/data/personal_incumbency_advantage.dta", clear

********************************************************************************

est clear

eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Brazil", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Brazil", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Brazil", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Brazil", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA14.tex", booktabs ///
keep(Conventional Robust) nomtitles ///
replace  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead(\begin{tabular}{l*{5}{c}} \toprule) ///
postfoot("") refcat(Conventional "\textbf{Panel A:} Brazil", nolabel)

est clear

eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Colombia", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Colombia", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Colombia", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Colombia", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA14.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot("")	refcat(elected "\textbf{Panel B:} Colombia", nolabel)

est clear

eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Denmark", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Denmark", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Denmark", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Denmark", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA14.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot("")	refcat(Conventional "\textbf{Panel C:} Denmark", nolabel)

est clear

eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Finland", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Finland", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(mserd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "MSE"
estadd local polynomial "Quadratic"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Finland", c(0) rho(1) p(1) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Linear"
eststo: rdrobust incumbent rv if rv!=0 & rv!=. & country=="Finland", c(0) rho(1) p(2) all vce(cluster constituency) kernel(uniform) bwselect(cerrd)
scalar bw =  e(h_l)
estadd local N_obs = e(N_h_l) + e(N_h_r)
estadd scalar bw
estadd local bandwidth "CER"
estadd local polynomial "Quadratic"

esttab est* using "$dir/tables/table_OA14.tex", booktabs ///
keep(Conventional Robust) nomtitles nonumbers ///
append  nonotes ///
ci(%9.3f) b(%9.3f) stats(N_obs h_l bandwidth polynomial, fmt(0 2)  layout(@) ///
labels("\textit{N}" "Bandwidth" "Bandwidth selector" "Polynomial")) collabels(none) ///
label nostar	eqlabels(none) ///
prehead("") ///
postfoot(\bottomrule \end{tabular})	refcat(elected "\textbf{Panel D:} Finland", nolabel)

est clear
